<!--
 * @Description: 案件管理
 * @Author: chaizhou
 * @Date: 2023-02-20 17:11:31
 * @LastEditTime: 2023-03-01 10:27:36
-->

<template>
  <h1>
    用户名称：{{ user.name }} -- {{ user.age }}岁
    <button @click="clickFn">子应用修改用户名称</button>
  </h1>
</template>

<script setup>
import { onMounted, reactive } from 'vue'
import selfActions from '@/stores/actions'

import { storeToRefs } from 'pinia'
import { useShareStore } from '@/stores/useShareStore'
const userStore = useShareStore()
const { user } = storeToRefs(userStore)

const useInfo = reactive(selfActions.actions.getStateCustom())
const clickFn = () => {
  const newState = { ...useInfo }
  newState.user = { name: '疯驴子', age: 50 }
  selfActions.actions.setGlobalState(newState)
}
onMounted(() => {
  // selfActions.actions.onGlobalStateChange((state, _) => {
  //   useInfo.user = state.user;
  // }, true);
})
</script>



<style lang="scss" scoped></style>
